package com.hhs.storage.bean;

import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;
import java.io.Serializable;

/**
 * <p>
 * 周出勤设置bean
 * </p>
 *
 * @author yuanjun
 * @since 2024-01-20
 */
@Data
public class ZrAttendanceSetting implements Serializable {

    private static final long serialVersionUID = 1L;
    public static final Integer WORKTIME = 7;
    public static final String  WORKVALUE= WORKTIME+","+WORKTIME+","+WORKTIME+","+WORKTIME+","+WORKTIME+","+0+","+0;
    /**
     * 出勤设置id
     */
    @ApiModelProperty(name = "id",value = "出勤设置id",required = true)
    private String id;

    /**
     * 0.部门，1个人
     */
    @ApiModelProperty(name = "type",value = "0.部门，1个人",required = false)
    private Integer type;

    /**
     * type为0.部门id,1.个人id
     */
    @ApiModelProperty(name = "type",value = "type为0.部门id,1.个人id，与type全空为部门领导",required = false)
    private String targetId;

    /**
     * 设置保存日期
     */
    @JSONField(format = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(name = "createDate",value = "设置保存时间",required = true)
    private LocalDate createDate;

    /**
     * 设置天这周周一的日期
     */
    @JSONField(format = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(name = "startDate",value = "设置天这周周一的日期",required = true)
    private LocalDate startDate;

    /**
     * 设置天这周周日的时间
     */
    @JSONField(format = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(name = "endDate",value = "设置天这周周日的日期",required = true)
    private LocalDate endDate;

    /**
     * 周一工作小时数
     */
    @ApiModelProperty(name = "att1",value = "周一工作小时数",required = false)
    private Integer att1;

    /**
     * 周二工作小时数
     */
    @ApiModelProperty(name = "att2",value = "周二工作小时数",required = false)
    private Integer att2;

    /**
     * 周三工作小时数
     */
    @ApiModelProperty(name = "att3",value = "周三工作小时数",required = false)
    private Integer att3;

    /**
     * 周四工作小时数
     */
    @ApiModelProperty(name = "att4",value = "周四工作小时数",required = false)
    private Integer att4;

    /**
     * 周五工作小时数
     */
    @ApiModelProperty(name = "att5",value = "周五工作小时数",required = false)
    private Integer att5;

    /**
     * 周六工作小时数
     */
    @ApiModelProperty(name = "att6",value = "周六工作小时数",required = false)
    private Integer att6;

    /**
     * 周日工作小时数
     */
    @ApiModelProperty(name = "att7",value = "周日工作小时数",required = false)
    private Integer att7;

    /**
     * 0正常班，1大小周，2隔天上，3自由定义,4总天数
     */
    @ApiModelProperty(name = "workType",value = "0正常班，1大小周，2隔天上，3自由定义,4总天数",required = true)
    private Integer workType;
    /**
     * 0普通人，1.领导(机动时间上班的人)
     */
    @ApiModelProperty(name = "personType",value = "0普通人，1.领导(机动时间上班的人)，空也为普通人",required = false)
    private Integer personType;
    /**
     * 数上班时长
     */
    @ApiModelProperty(name = "totalHours",value = "personType为1时设置",required = false)
    private Integer totalHours;
    /**
     * 得到默认的状态
     * @param inputParam
     * @return
     */
    public static ZrAttendanceSetting getInstanceDefault(InputParam inputParam){
        ZrAttendanceSetting res=new ZrAttendanceSetting();
        res.setTargetId(inputParam.getId());
        res.setType(inputParam.getType());
        res.setPersonType(inputParam.getPersonType());
        if(inputParam.getPersonType()==null||inputParam.getPersonType()==0){
            res.setAtt1(ZrAttendanceSetting.WORKTIME);
            res.setAtt2(ZrAttendanceSetting.WORKTIME);
            res.setAtt3(ZrAttendanceSetting.WORKTIME);
            res.setAtt4(ZrAttendanceSetting.WORKTIME);
            res.setAtt5(ZrAttendanceSetting.WORKTIME);
            res.setAtt6(0);
            res.setAtt7(0);
            res.setWorkType(0);
        }else if(1==inputParam.getPersonType()){
            res.setWorkType(4);
            res.setTotalHours(28);
        }
        return res;
    }
}
